/*************************************************************************
> File Name: person.cpp
> Author: hzy
> Created Time: 2023-08-17 14:02:19
> Description:
************************************************************************/
#include "person.h"

// 有参构造函数
Person::Person(string myname, int myage)
{
    name = myname;
    age = myage;
}
// 无参构造
Person::Person()
{
    name = " ";
    age = 0;
}

// 成员函数
// 设置名字
void Person::setName(string myname)
{
    name = myname;
}
// 获取名字
string Person::getName()
{
    return name;
}
// 设置年龄
void Person::setAge(int myage)
{
    age = myage;
}
// 获取年龄
int Person::getAge()
{
    return age;
}

// 重载赋值运算符
Person &Person::operator=(const Person &other)
{
    if (this != &other)
    {
        this->name = other.name;
        this->age = other.age;
    }
    return *this;
}

// 重载<<操作符
ostream &operator<<(ostream &os, const Person &person)
{
    os << person.name << "|" << person.age;
}
